//
//  AXMyWdzcViewController.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/19.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMyWdzcVC.h"
#import "ZXCategories.h"
#import "UIView+SDAutoLayout.h"
#import "MyCouponsViewController.h"
@interface AXMyWdzcVC ()

@property (nonatomic , strong) UIImageView *leftImageView;
/** 余额 */
@property (nonatomic , strong) UILabel *yeLabel;
/** 余额数*/
@property (nonatomic , strong) UILabel *moneyLabel;
/** 明细*/
@property (nonatomic , strong) UIButton *detailButton;
@property (nonatomic , strong) UIImageView *rightImageView;
/** 充值按钮 */
@property (nonatomic , strong) UIButton *czButton;
/** 提现按钮*/
@property (nonatomic , strong) UIButton *txButton;
/** 优惠券 */
@property (nonatomic , strong) UILabel *discountLabel;
/** 优惠券数*/
@property (nonatomic , strong) UILabel *discountCountLabel;

@end

@implementation AXMyWdzcVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    [self setupNavigationItems];
    [self creatView];
    [self setlayout];
}

- (void)creatView {
    
    self.leftImageView = [[UIImageView alloc]init];
    self.leftImageView.backgroundColor = [UIColor whiteColor];
    self.leftImageView.image = [UIImage imageNamed:@"jx"];
    [self.view addSubview:self.leftImageView];
    
    self.yeLabel = [[UILabel alloc]init];
    self.yeLabel.textAlignment = NSTextAlignmentCenter;
    self.yeLabel.text = @"余额";
    self.yeLabel.font = FONT_SIXTEEN;
    [self.leftImageView addSubview:self.yeLabel];
    
    self.moneyLabel = [[UILabel alloc]init];
    self.moneyLabel.textAlignment = NSTextAlignmentCenter;
    self.moneyLabel .text = @"¥444.44";
    self.moneyLabel.textColor  =COLOR_ORG;
    self.moneyLabel .font = FONT_SIXTEEN;
    [self.leftImageView addSubview:self.moneyLabel ];
    
    self.detailButton = [[UIButton alloc]init];
    [self.detailButton addTarget:self action:@selector(detail:) forControlEvents:UIControlEventTouchUpInside];
    self.detailButton.titleLabel.font = FONT_SIXTEEN;
    [self.detailButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.detailButton setTitle:@"明细" forState:UIControlStateNormal];
    [self.leftImageView addSubview:self.detailButton];
    
    
    
    self.rightImageView = [[UIImageView alloc]init];
    self.rightImageView.backgroundColor = [UIColor whiteColor];
    self.rightImageView.image = [UIImage imageNamed:@"jx"];
    [self.view addSubview:self.rightImageView  ];
    
    self.discountLabel = [[UILabel alloc]init];
    self.discountLabel.textAlignment = NSTextAlignmentCenter;
    self.discountLabel.text = @"余额";
    self.discountLabel.font = FONT_SIXTEEN;
    [self.rightImageView addSubview:self.discountLabel];
    
    self.discountCountLabel = [[UILabel alloc]init];
    self.discountCountLabel.textAlignment = NSTextAlignmentCenter;
    self.discountCountLabel .text = @"100";
    self.discountCountLabel.textColor  =COLOR_ORG;
    self.discountCountLabel .font = FONT_SIXTEEN;
    [self.rightImageView addSubview:self.discountCountLabel ];
    
    self.czButton = [[UIButton alloc]init];
    self.czButton.backgroundColor = COLOR_ORG;
    [self.czButton setTitle:@"充值" forState:UIControlStateNormal];
    [self.czButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:self.czButton];
    
    self.txButton = [[UIButton alloc]init];
    self.txButton.backgroundColor = COLOR_GREEN;
    [self.txButton setTitle:@"提现" forState:UIControlStateNormal];
    [self.txButton addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
    [self.txButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:self.txButton];
    
    
    
}

- (void)setlayout {
    
    self.leftImageView.sd_layout
    .leftSpaceToView(self.view, 10)
    .topSpaceToView(self.view, NAVIGATION_HEIGHT+50)
    .widthIs((SCREEN_WIDTH - 50)/2)
    .heightIs((SCREEN_WIDTH - 50)/2);
    
    self.yeLabel.sd_layout
    .centerXEqualToView(self.leftImageView)
    .topSpaceToView(self.leftImageView, 50)
    .widthIs(100)
    .heightIs(30);
    
    self.moneyLabel.sd_layout
    .centerXEqualToView(self.leftImageView)
    .topSpaceToView(self.yeLabel, 5)
    .widthIs(100)
    .heightIs(30);
    
    self.detailButton.sd_layout
    .centerXEqualToView(self.leftImageView)
    .topSpaceToView(self.moneyLabel, 5)
    .widthIs(100)
    .heightIs(30);
    
    
    
    
    self.rightImageView.sd_layout
    .rightSpaceToView(self.view, 10)
    .topSpaceToView(self.view, NAVIGATION_HEIGHT+50)
    .widthIs((SCREEN_WIDTH - 50)/2)
    .heightIs((SCREEN_WIDTH - 50)/2);
    
    self.discountLabel.sd_layout
    .centerXEqualToView(self.rightImageView)
    .topSpaceToView(self.rightImageView, 50)
    .widthIs(50)
    .heightIs(30);
    
    self.discountCountLabel.sd_layout
    .centerXEqualToView(self.rightImageView)
    .topSpaceToView(self.discountLabel, 5)
    .widthIs(50)
    .heightIs(30);
    
    
    self.czButton.sd_layout
    .centerXEqualToView(self.view)
    .topSpaceToView(self.leftImageView, 40)
    .widthIs(100)
    .heightIs(30);
    
    self.txButton.sd_layout
    .centerXEqualToView(self.view)
    .topSpaceToView(self.czButton,10)
    .widthIs(100)
    .heightIs(30);
    
    
    
    
    
}


#pragma mark - action

- (void)detail:(UIButton *)btn {
    
}



- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    /** 搜索 */
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    titleLabel.text = @"我的资产";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = FONT_EIGHTEEN;
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    self.navigationItem.titleView = titleLabel;
    
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)search:(UIButton *)btn {
    
}

- (void)clickAction {
    
    MyCouponsViewController *vc = [MyCouponsViewController new];
    [self.navigationController pushViewController:vc animated:YES];
    
}

@end
